<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <!-- 理想视口 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <!-- 基础样式，包含  头部  搜索框  底部 -->
    <link rel="stylesheet" href="../css/base.css">

    <link rel="stylesheet" href="../css/coupon-list.css">
    <title>Document</title>
</head>

<body>
    <!-- 头部 -->
<header>

    <a href="./coupon.html">
        <img src="../images/getmoneyctrl_left.png" alt="">
    </a>
    <h2>优惠券</h2>

    <a href="javascript:;">
        <img src="../images/header_app.png" alt="">
    </a>

</header>
    <!-- 小标题 -->
    <h1>--点餐前出示手机优惠券，即可享受优惠--</h1>
    <!-- 内容 -->
    <div class="content">
        <ul>
            
        </ul>
    </div>
    <!-- 底部 -->

</body>

</html>
<script src="../lib/zepto/dist/zepto.min.js"></script>
<!-- art-template模板 -->
<script src="../lib/art-template/template-web.js"></script>
<!-- base文件中包含响应式字体设置等方法 -->
<script src="../js/base.js"></script>

<!-- 模板 -->
<script type="text/template" id='coupon-list'>
    {{ each result value key}}
<li class="clearfix">
    <a href="">
         {{@value.couponProductImg}}
        <h4>{{value.couponProductName}}</h4>
        <div>{{value.couponProductPrice}}</div>
        <p>{{value.couponProductTime}}</p>
    </a>
</li>
    {{ /each }}
</script>


<script>
    $(function () {

/*取到url的参数*/
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
// if (r != null) return unescape(r[2]);
if (r != null) return decodeURI(r[2]);
return null;
}
        $.ajax({
            url: "http://193.112.55.79:9090/api/getcouponproduct",
            type: 'get',
            data: {
couponid: getQueryString("id")
            },
            dataType: 'json',
            success: function (res) {
                console.log(res);
var htmlStr = template('coupon-list', res)
$('.content ul').html(htmlStr)

            }
        })
    })
</script>